#pragma once
#include "workqueue.h"
namespace Common
{
	class DefaultWorkQueue :
		public WorkQueue
	{
	public:
		DefaultWorkQueue( const std::string& strWorkQueueName = "" );
		virtual ~DefaultWorkQueue(void);

		/// Main function for each thread spawned.
		virtual void _threadMain();

		/// @copydoc WorkQueue::shutdown
		virtual void shutdown();

		/// @copydoc WorkQueue::startup
		virtual void startup(bool forceRestart = true);

	protected:
		/** To be called by a separate thread; will return immediately if there
		are items in the queue, or suspend the thread until new items are added
		otherwise.
		*/
		virtual void waitForNextRequest();

		/// Notify that a thread has registered itself with the render system
		virtual void notifyThreadRegistered();

		virtual void notifyWorkers();

		size_t m_NumThreadsRegisteredWithRS;
		/// Init notification mutex (must lock before waiting on initCondition)
		MUTEX(m_InitMutex)
			/// Synchroniser token to wait / notify on thread init 
			THREAD_SYNCHRONISER(m_InitSync)
			THREAD_SYNCHRONISER(m_RequestCondition)

			typedef std::vector<THREAD_TYPE*> WorkerThreadList;
		WorkerThreadList m_Workers;
	};

}